package com.redball;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.MotionEvent;

public abstract class GraphicObject
{
	private Bitmap _bitmap;
	private Coordinates _coordinates;

	public GraphicObject(Bitmap bitmap)
	{
		this(bitmap, 200, 800);
	}

	public GraphicObject(Bitmap bitmap, int x, int y)
	{
		_bitmap = bitmap;
		_coordinates = new Coordinates(x, y);
	}

	public Bitmap getGraphic()
	{
		return _bitmap;
	}

	public Coordinates getCoordinates()
	{
		return _coordinates;
	}

	public abstract void updatePhysics();
	
	public void draw(Canvas canvas)
	{
		canvas.drawBitmap(getGraphic(), getCoordinates().getX(), getCoordinates()
				.getY(), null);
	}

	public abstract void handleColission(double normal);
	
	public abstract boolean onTouchEvent(MotionEvent event);
	
	/**
	 * Contains the coordinates of the graphic.
	 */
	public class Coordinates
	{
		private int _x;
		private int _y;

		public Coordinates(int x, int y)
		{
			_x = x;
			_y = y;
		}

		public int getX()
		{
			return _x;
		}

		public void setX(int value)
		{
			_x = value;
		}

		public int getY()
		{
			return _y;
		}

		public void setY(int value)
		{
			_y = value;
		}

		public String toString()
		{
			return "Coorginates: (" + _x + "/" + _y + ")";
		}
		
		

	}

	public abstract void handleObjectColission(Coordinates coordinates);
}
